﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using DailyDiet.Models;

namespace DailyDiet.Services
{
    /// <summary>
    /// 菜品收藏类
    /// </summary>
    public interface IFavoriteStorageService
    {
        /// <summary>
        /// 初始化食物存储
        /// </summary>
        Task InitializeAsync();

        /// <summary>
        /// 收藏存储是否已经初始化
        /// </summary>
        bool IsInitialized();

        /// <summary>
        /// 获得一个食品收藏信息
        /// </summary>
        /// <param name="dietId">食品ID</param>
        Task<Favorite> GetFavoriteAsync(int dietId);

        /// <summary>
        /// 保存收藏信息
        /// </summary>
        /// <remarks>收藏信息包括食品ID和是否收藏</remarks>
        /// <param name="favorite">收藏</param>
        Task RefreshFavorite(Favorite favorite);

        /// <summary>
        /// 获得所有收藏信息
        /// </summary>
        /// <returns></returns>
        Task<List<Favorite>> GetFavoritesAsync();
        
        Task CloseConnection();
    }

    /// <summary>
    /// 收藏存储常量
    /// </summary>
    public static class FavoriteStorageConstants {
        /// <summary>
        /// 收藏数据库版本号
        /// </summary>
        public const int VERSION = 1;

        /// <summary>
        /// 默认的收藏数据库版本号
        /// </summary>
        public const int DEFAULTVERSION = -1;

        /// <summary>
        /// 收藏数据库版本号键
        /// </summary>
        public const string VersionKey = nameof(FavoriteStorageConstants) + "." +
            nameof(VERSION);
    }
}
